
local sdl = require 'bindings.sdl'
local tonumber, assert, require, print
    = tonumber, assert, require, print
local floor
    = math.floor


module (...)


local width, height

function dimensions(new_width, new_height)
  if new_width then
    width, height = assert(tonumber(new_width), "width must be a number"), assert(tonumber(new_height), "height must be a number")
  else
    return width, height
  end
end

local window
local windowWidth, windowHeight
local windowX, windowY

function declareWindowSize(w,h)
  windowX, windowY = floor((w-width)/2), floor((h-height)/2)
  local scaleX, scaleY = 1, 1
  local maxX, maxY = width, height
  window.declareMouseOffset(-windowX, -windowY)
  window.declareMouseScale(scaleX, scaleY)
  window.declareMouseMax(maxX, maxY)
end

function init()
  window = require 'guac.window'
  assert(window.init_sdl, "window mode does not support sdl")()
end

local back_r, back_g, back_b = 0, 0, 0

function backgroundColor(new_r, new_g, new_b)
  if new_r then
    back_r, back_g, back_b = new_r, new_g, new_b
  else
    return back_r, back_g, back_b
  end
end

local function _onrender() end
function declareRenderFunc(func)
  _onrender = func
end

function internal_render()
  sdl.FillRect(sdl.GetVideoSurface(), nil, 0)
  _onrender()
  sdl.Flip(sdl.GetVideoSurface())
end

function loadImage(path)  
end

function drawImage(img, x, y)
end
